#include "EditFoodWindow.h"
#include "ui_EditFoodWindow.h"

QString _name = "";

EditFoodWindow::EditFoodWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::EditFoodWindow)
{
    ui->setupUi(this);
}

EditFoodWindow::~EditFoodWindow()
{
    delete ui;
}

//加载ui界面
void EditFoodWindow::init(Food food){
    ui->name_et->setText(food.name);
    ui->price_et->setText(QString::number(food.price));
    ui->content_et->setText(food.content);
    _name = food.name;
}

//确认修改
void EditFoodWindow::on_edit_btn_clicked(){
    FoodTable food_table;
    Food food;
    food.name = ui->name_et->toPlainText();
    food.price = ui->price_et->toPlainText().toInt();
    food.content = ui->content_et->toPlainText();
    food.is_null = 0;

    food_table.updateFoodInform(food,_name);

    emit dataChange();
    //隐藏
    this->hide();
}
